<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="report" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 增加报表 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="名称" prop="description">
              <el-input v-model="report.description" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="类型" prop="type">
              <el-select style='width:100%' v-model="report.type">
                <el-option label="列表" value="list" />
                <el-option label="柱状图" value="bar" />
                <el-option label="线状图" value="line" />
                <el-option label="饼状图" value="pie" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 报表参数 </span>
      </div>
      <el-table :data="mvc_add_list">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(mvc_add_list,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(mvc_add_list,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="参数" prop="">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name" />
          </template>
        </el-table-column>
        <el-table-column label="参数说明" prop="">
          <template slot-scope="scope">
            <el-input v-model="scope.row.description" />
          </template>
        </el-table-column>
        <el-table-column label="类型" prop="">
          <template slot-scope="scope">
            <el-select style='width:100%' v-model="scope.row.type">
              <el-option label="文本框" value="input" />
              <el-option label="单选框" value="radio" />
              <el-option label="下拉框" value="select" />
              <el-option label="日期框" value="timebox" />
            </el-select>
          </template>
        </el-table-column>
      </el-table>
      <div class="form-unit">
        <span class="mvc-title-left"> 列表项 </span>
      </div>
      <el-table :data="mvc_add_list">
        <el-table-column label="操作" prop="" width="60">
          <template slot-scope="scope">
            <el-link @click="appendRow(mvc_add_list,scope)" type='primary'><i class='el-icon-plus' title='增加行' /></el-link>
            <el-link @click="delRow(mvc_add_list,scope)" type='danger'><i class='el-icon-minus' title='删除行' /></el-link>
          </template>
        </el-table-column>
        <el-table-column label="名称" prop="">
          <template slot-scope="scope">
            <el-input v-model="scope.row.name" />
          </template>
        </el-table-column>
        <el-table-column label="参数说明" prop="">
          <template slot-scope="scope">
            <el-input v-model="scope.row.description" />
          </template>
        </el-table-column>
      </el-table>
      <el-button @click="reportAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ReportAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        report: {
          description: null,
          type: null,
        },
        mvc_add_list: [],
        loading: false,
        rules: {
          description: [{
            required: true,
            message: "名称不能为空",
            trigger: 'blur',
          }],
          type: [{
            required: true,
            message: "类型不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {},
    updated() {},
    mounted() {},
    methods: {
      reportAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/systemadmin/ReportAdminAction/reportAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/systemadmin/ReportDetail/reportDetail?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      insert(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/mes/systemadmin/ReportAdminAction/insert?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
    },
  }
</script>
